<form action="receive.manage.php?action=addsave" method="POST" style="line-height:30px" id="form_add">
<table width="100%"  class="from_table">
  <tr>
    <th width="20%" height="30" valign="middle"><tpl> $langRAccounts </tpl>:</th>
    <td width="80%" height="30"><input name="txtMemberName" class="txtinput" type="text" id="txtMemberName" value="" /></td>
  </tr>
  <tr>
    <th height="30" valign="middle"><tpl> $langRConsigneeName </tpl>:</th>
    <td height="30"><input name="txtReceiveName" class="txtinput" type="text" id="txtReceiveName" value="" /></td>
  </tr>
  <tr>
    <th height="30" valign="middle"><tpl> $langRLocalityZone </tpl>:</th>
    <td height="30"><tpl> $langRProvince </tpl>:
      <input type="hidden" name="area_id" id="area_id" value="<tpl> $product_array.p_area_id </tpl>"/>
		<select id="area_c1" class="searchformselect" name="area_c1" style="width: 120px">
			<option valus="" selected></option>
			<tpl> foreach item = parent from = $area_array </tpl>
			<option <tpl> if $sel_area[0].area_id eq $parent.area_id </tpl>selected="selected"<tpl> /if  </tpl> value="<tpl>$parent.area_id</tpl>||<tpl>$parent.is_parent</tpl>"><tpl> $parent.area_name </tpl></option>
			<tpl> /foreach </tpl>
		</select>
		<select class="searchformselect" id="area_c2" style="width: 120px" name="area_c2">
			<option valus="<tpl> $sel_area[1].area_id </tpl>" selected><tpl> $sel_area[1].area_name </tpl></option>
		</select>
		<select class="searchformselect" id="area_c3" style="width: 120px" name="area_c3">
			<option valus="<tpl> $sel_area[2].area_id </tpl>" selected><tpl> $sel_area[2].area_name </tpl></option>
		</select>
		<select class="searchformselect" id="area_c4" style="width: 120px" name="area_c4">
			<option valus="<tpl> $sel_area[3].area_id </tpl>" selected><tpl> $sel_area[3].area_name </tpl></option>
		</select>
	</td>
  </tr>
  <tr>
    <th height="30" valign="middle"><tpl> $langRParticularAddress </tpl>:</th>
    <td height="30"><textarea name="txtAddress"  class="tarea" cols="50" id="txtAddress"></textarea></td>
  </tr>
  <tr>
    <th height="30" valign="middle"><tpl> $langReceivePostalcode </tpl>:</th>
    <td height="30"><input name="txtZip" type="text" class="txtinput" id="txtZip" value="" /></td>
  </tr>
  <tr>
    <th height="30" valign="middle"><tpl> $langRPhone </tpl>:</th>
    <td height="30"><input name="txtPhone" type="text" class="txtinput" id="txtPhone" value="" /></td>
  </tr>
  <tr>
    <th height="30" valign="middle"><tpl> $langRMobileTelephone </tpl>:</th>
    <td height="30"><input name="txtMobilephone" type="text"  class="txtinput" id="txtMobilephone" value="" /></td>
  </tr>
  <tr>
    <td height="30" style="padding-left:10px">
			</td>
    <td height="30">
	<span class="btn_left">
	<input type="submit" name="submit" value="<tpl> $langCsubmit </tpl>" />
	</span>
	<span class="btn_left">
		<input id="butt_list" type="button" value="<tpl> $langRReturnList </tpl>" />
		</span>
		</td>
  </tr>
</table>
<input type="hidden" name="receive_id" value=""><input type="hidden" name="member_id" value="">
</form>
<script language="javascript">
$(document).ready(function() {
	hideMessage();
	//返回列表
	$('#butt_list').click(function(){
		ShowDiv = "result_content";
		getPageContent("receive.manage.php?action=ajax_list");
	})
	
	var options_add = {
		beforeSubmit:  function(){showLoading(showText);},
		success:       function(msg){
						hideLoading();
						showMessage(msg.message,msg.type);
						if(msg.type == '1'){
							ST(0,0);
							ShowDiv = "result_content";
							getPageContent("receive.manage.php?action=ajax_list");
						}
					},
		type:      'post',
		dataType:  'json'
	};
	$("#form_add").validate({
		errorClass: "wrong",
		rules: {
			txtMemberName: {required:true},
			txtReceiveName: {required:true},
			txtProvince: {required:true},
			txtAddress: {required:true},
			txtZip: {required:true},
			txtPhone: {required:true,number:true},
			txtMobilephone: {number:true}
		},
		messages: {
			txtMemberName: {required:"<tpl> $langRAccountsCannotNull </tpl>"},
			txtReceiveName: {required:"<tpl> $langRConsigneeNameNotNull </tpl>"},
			txtProvince: {required:"<tpl> $langRLocalityProvinceCanNotNull </tpl>"},
			txtAddress: {required:"<tpl> $langRParticularAddressNotNull </tpl>"},
			txtZip: {required:"<tpl> $langRPostalcodeNotNull </tpl>"},
			txtPhone: {required:"<tpl> $langRPhoneCannotNull </tpl>",number:"<tpl> $langRPhoneIsNumber </tpl>"},
			txtMobilephone: {number:"<tpl> $langRMobileTelephoneIsNumber </tpl>"}			
		},
		submitHandler: function() {
			$('#form_add').ajaxSubmit(options_add);
		}
	});	
});
//地区选择
function tonext_area(whos) {
	$(whos).change(
		function(){
			var valarray=$(this).val().split('||');	
			$('#area_id').val(valarray[0]);
			if (valarray[1]=='1') {
				$(this).next().attr('disabled','true').html('<option value="" selected="selected"><tpl> $langCDataToLoading </tpl></option>');
				$.get(
					'../home/tohtml.php',
					{action:'get_area',id:valarray[0],random_number:Math.random()},
					function(data){
						DataArray = data.split("|||");
						var a='';
						for (var i = 0; i<DataArray.length-1; i++) {
							att=DataArray[i].split("||");
							id=att[0];
							cla=att[2];
							a+='<option value="'+id+'||'+cla+'">'+att[1]+((cla=='1')?' ->':'')+'</option>';
						}
						
					$(whos).next().removeAttr('disabled').html('<option value="" selected="selected"></option>'+a).nextAll().html('');
					tonext_area($(whos).next());
					}
				)
			} else {
				$(whos).nextAll().html('').attr('disabled','true');
			};
		}
	)
};
$(document).ready(function() {
	tonext_area('#area_c1');
});
</script>